#include <iostream>
#include <stack>
#include <string>

bool isBracketSequenceCorrect(const std::string& sequence) {
    std::stack<char> brackets;
    const std::string opening = "([{<";
    const std::string closing = ")]}>";

    for (char bracket : sequence) {
        if (opening.find(bracket) != std::string::npos) {
            brackets.push(bracket);
        } else if (closing.find(bracket) != std::string::npos) {
            if (brackets.empty() || opening.find(brackets.top()) != closing.find(bracket)) {
                return false;
            }
            brackets.pop();
        }
    }

    return brackets.empty();
}

int main() {
    std::string sequence;
    std::cout << "Введите скобочную последовательность: ";
    std::cin >> sequence;

    bool isCorrect = isBracketSequenceCorrect(sequence);
    std::cout << (isCorrect ? "True" : "False") << std::endl;

    return 0;
}
